package com.xiaoshuidi.cloud.module.finance.job.reconciliation;

import com.xiaoshuidi.cloud.framework.common.exception.ServiceException;
import com.xiaoshuidi.cloud.module.finance.service.finance.YinlianReconciliationService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 银联对账
 */
@Slf4j
@Component("yinlianReconciliationJob")
public class YinlianReconciliationJob {
    @Resource
    private YinlianReconciliationService yinlianReconciliationService;

    @Async
    @XxlJob("yinlianReconciliationJob")
    public void execute() throws Exception {
        try {
            log.info("对账任务开始");
            yinlianReconciliationService.reconciliation();
        } catch (ServiceException e) {
            log.info("对账任务异常", e);
            XxlJobHelper.handleFail("拉取银联对账失败, " + e.getMessage());
        }
    }
}
